package cn.iocoder.yudao.framework.base.common.mysql.sequence;


import org.springframework.stereotype.Component;

import jakarta.annotation.Resource;

@Component
public class MysqlSequenceFactory {

    @Resource
    private SeqService seqService;

    public synchronized MysqlSequence create(String seq_name) {
        int countSeq = seqService.countSeq(seq_name);
        if (countSeq == 0) {
            seqService.insert(seq_name);
        }
        MysqlSequence mysqlSequence = new MysqlSequence(seqService, seq_name);

        return mysqlSequence;
    }

}
